package qvanguoobject.test04;

import java.util.Scanner;

public class StudentTest {
    public static void main(String[] args) {
        // 创建五个Student对象
        Scanner sc = new Scanner(System.in);

        Student[] students = new Student[5];
        for (int i = 0; i < students.length; i++) {
            System.out.println("请输入第"+(i+1)+"个学生的信息:");
            students[i] = new Student(sc.nextLine(),sc.nextLine(),sc.nextLine(),sc.nextInt(),sc.nextDouble());
        }

        // 输出每个学生的信息
        System.out.println("学生信息如下：");
        for (Student s : students) {
            System.out.printf("学号：%s，姓名：%s，性别：%s，年龄：%d，Java成绩：%.1f%n",
                    s.getNo(), s.getName(), s.getSex(), s.getAge(), s.getJava());
        }

        // 计算并输出Java成绩的平均值、最大值和最小值
        double sum = 0;
        double max = students[0].getJava();
        double min = students[0].getJava();

        for (Student s : students) {
            double score = s.getJava();
            sum += score;
            if (score > max) {
                max = score;
            }
            if (score < min) {
                min = score;
            }
        }

        double avg = sum / students.length;

        System.out.println("\nJava成绩统计：");
        System.out.printf("平均值：%.1f%n", avg);
        System.out.printf("最大值：%.1f%n", max);
        System.out.printf("最小值：%.1f%n", min);
    }
}
